package com.rd.sys.servlet.auth;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.rd.sys.common.base.CommonConstants;
import com.rd.sys.common.web.session.SessionUtil;
import com.rd.sys.dto.commmon.base.EyeResult;

public class HeartbeatServlet extends AuthBaseServlet {
    private static final long serialVersionUID = -7029462519255539578L;

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        EyeResult result = null;
        try {
            HttpSession session = SessionUtil.getSession(req);
            if (session == null || session.getAttribute(CommonConstants.UserConstats.USER_SESSION_FLAG) == null) {
                // Session不存在 或者 Session中用户信息不存在
                result = new EyeResult(EyeResult.ResultDefine.AUTH_SESSION_VOERDUE);
                return;
            }

            result = new EyeResult(EyeResult.ResultDefine.COMMON_SUCCESS);

        } catch (Exception ex) {
            logger.error("", ex);
            result = new EyeResult(EyeResult.ResultDefine.AUTH_LOGIN_FAIL);
        } finally {
            sendResponse(result, req, resp);
        }
    }
}
